<?php

namespace AppBundle\Controller;

use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route;
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
use AppBundle\Service\UserService;
use AppBundle\Service\LogService;
use Symfony\Component\HttpFoundation\Request;

class DefaultController extends Controller
{
    private  $logger;
    public function __construct(LogService $logger)
    {
        $this->logger = $logger;
    }

    /**
     * @Route("/", name="homepage")
     */
    public function indexAction(Request $request)
    {
        // replace this example code with whatever you need
        return $this->render('default/index.html.twig', [
            'base_dir' => realpath($this->getParameter('kernel.project_dir')).DIRECTORY_SEPARATOR,
        ]);
    }

    public function toHtml($args)
    {
        return "<p>{$args}</p>";
    }

    public function toHtmlFromReader(UserService $service)
    {
        $user=$service->getUser();
        return "<p>{$user}</p>";
    }

    public function outHtml($message)
    {
         $this->logger->log("<p>{$message}</p>");
    }
}
